package com.cupk.service.impl;

import com.cupk.common.PageResult;
import com.cupk.dto.AdminDto;
import com.cupk.dto.ProviderDto;
import com.cupk.dto.StorageDto;
import com.cupk.mapper.StorageMapper;
import com.cupk.service.StorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 名称StorageServiceImpl
 * 描述
 *
 * @version 1.0
 * @author:XiongRuiKai
 * @datatime:2023-06-14 16:29
 */
@Service
public class StorageServiceImpl implements StorageService {
    @Autowired
    private StorageMapper storageMapper;
    /**
     * 库存管理分页查询
     * @param id 物资编号
     * @param name 物资名称
     * @param number 物资库存
     * @param page 页码
     * @param pageSize 每页返回的数据条目数
     * @return
     */
    @Override
    public PageResult<StorageDto> getStoragePage(Integer id, String name, Integer number, int page, int pageSize) {
        int start = (page - 1) * pageSize;
        List<StorageDto> storageDto = storageMapper.getStoragePage(start, pageSize, id, name, number);
        long total = storageMapper.getStorageCount(id, name, number);
        return new PageResult<>(storageDto, total);
    }
}
